<include file="public/header" title="登录"  body=""/>
<include file="public/header_nav" title="登录"  href="javascript:history.back(-1);"/>
<div class="flool loginsignup2">
<!--LOGO-->
    <img src="__STATIC__/images/logo-login.png?v=1" alt="LOGO"/>
</div>
<div class="loginsingup-input">
<!--登录表单-s-->
    <form  id="loginform" method="post"  >
        <input type="hidden" name="referurl" id="referurl" value="{$referurl}">
        <div class="content30">
            <div class="lsu">
                <span>账号</span>
                <input type="text" name="username" id="username" value=""  placeholder="请输入手机号"/>
            </div>
            <div class="lsu">
                <span>密码</span>
                <input type="password" name="password" id="password" value="" placeholder="请输入密码"/>
                <i></i>
            </div>
            <!-- <notempty name="first_login">
            <div class="lsu test">
                <span>请输入验证码</span>
                <input type="text" name="verify_code" id="verify_code" value="" placeholder="请输入验证码"/>
                <img  id="verify_code_img" src="{:U('Mobile/User/verify')}" onClick="verify()"/>
            </div>
            </notempty> -->
            <div class="lsu submit">
                <input type="button"  value="提交"  onclick="submitverify()" class="btn_big1"  />
            </div>
            <div class="radio">
            </div>
            <div class="signup-find p">
                <div class="note fl">
                    <img src="__STATIC__/images/not.png"/>
                    <a href="{:U('User/reg')}"><span>快速注册</span></a>
                </div>
                <div class="note fr">
                    <img src="__STATIC__/images/ru.png"/>
                    <a href="{:U('User/forget_pwd')}"><span>找回密码</span>
                </div>
            </div>
        </div>
    </form>
<!--登录表单-e-->
</div>

<!--第三方登陆-s-->
<div class="thirdlogin">
        <h4>第三方登陆</h4>
        <ul>

        <li>
            <a class="ta-weixin" href="{:U('mobile/user/wx_login')}" target="_blank" title="weixin">
                <div class="icon">
                    <img src="__STATIC__/images/wechat.png"/>
                    <p>微信登陆</p>
                </div>
            </a>
        </li>
    <!-- <if condition="$v['code'] eq 'alipay' AND is_alipay() neq 1">
        <li>
            <a href="{:U('LoginApi/login',array('oauth'=>'alipay'))}">
                <div class="icon">
                    <img src="__STATIC__/images/alpay.png"/>
                    <p>支付宝</p>
                </div>
            </a>
        </li>
    </if>
    <if condition="$v['code'] eq 'qq' AND is_qq() neq 1">
        <li>
            <a class="ta-qq" href="{:U('LoginApi/login',array('oauth'=>'qq'))}" target="_blank" title="QQ">
                <div class="icon">
                    <img src="__STATIC__/images/qq.png"/>
                    <p>qq登陆</p>
                </div>
            </a>
        </li>
    </if> -->
        </ul>		
</div>
<!--第三方登陆-e-->

<script type="text/javascript">
    function verify(){
        $('#verify_code_img').attr('src','/index.php?m=Mobile&c=User&a=verify&r='+Math.random());
    }

    //复选框状态
    function remember(obj){
         var che= $(obj).attr("class");
        if(che == 'che check_t'){
            $("#autologin").prop('checked',false);
        }else{
            $("#autologin").prop('checked',true);
        }
    }
    function submitverify()
    {
        var username = $.trim($('#username').val());
        var password = $.trim($('#password').val());
        var remember = $('#remember').val();
        var referurl = $('#referurl').val();
        var verify_code = $.trim($('#verify_code').val());
        if(username == ''){
            showErrorMsg('用户名不能为空!');
            return false;
        }
        if(!checkMobile(username) && !checkEmail(username)){
            showErrorMsg('账号格式不匹配!');
            return false;
        }
        if(password == ''){
            showErrorMsg('密码不能为空!');
            return false;
        }
        var codeExist = $('#verify_code').length;
        if (codeExist && verify_code == ''){
            showErrorMsg('验证码不能为空!');
            return false;
        }

        var data = {username:username,password:password,referurl:referurl};
        if (codeExist) {
            data.verify_code = verify_code;
        }
        $.ajax({
            type : 'post',
            url : '/index.php?m=Mobile&c=User&a=do_login&t='+Math.random(),
            data : data,
            dataType : 'json',
            success : function(data){
                if(data.status == 1){
                    var url = data.url.toLowerCase();
                    if (url.indexOf('user') !=  false && url.indexOf('login') != false || url == '') {
                        window.location.href = '/index.php/mobile';
                    }else{
                        window.location.href = data.url;
                    }
                }else{
                    showErrorMsg(data.msg);
                    if (codeExist) {
                        verify();
                    } else {
                        location.reload();
                    }
                }
            },
            error : function(XMLHttpRequest, textStatus, errorThrown) {
                showErrorMsg('网络异常，请稍后重试');
            }
        })
    }
        //切换密码框的状态
        $(function(){
            $('.loginsingup-input .lsu i').click(function(){
                $(this).toggleClass('eye');
                if ($(this).hasClass('eye')) {
                    $(this).siblings('input').attr('type','text')
                } else{
                    $(this).siblings('input').attr('type','password')
                }
            });
        })
    </script>
</body>
</html>
